// 第一步:引入路由器
import { createRouter, createWebHistory } from "vue-router";

// 引入一个可能需要呈现的组件
import Home from "@/components/Home.vue";
import User from "@/components/User.vue";
import Product from "@/components/Product.vue";
import Detail from "@/components/Detail.vue";

// 第二步:创建路由
const routes = [
    {
        path: '/home',
        component: Home
    },{
        path: '/user',
        component: User
    },{
        name: 'sp',
        path: '/product',
        component: Product,
        children:[{
            name: 'xq',
            // 嵌套的路由不能以/开头
            // 传递params参数时,需要提前在规则中进行占位
            path: 'detail/:id/:name/:price',  
            component: Detail
        }]
    }
]
const router = createRouter({
    history: createWebHistory(),    // 路由工作模式
    routes
})
// 将路由暴露出去
export default router